import sys
import os

from celery import Celery

from app.chess import create_app

print("gevent wsgi server start!")

try:
    from gevent.pywsgi import WSGIServer
except Exception as e:
    from gevent.wsgi import WSGIServer


app = create_app()
# app.debug = True
app.use_gevent = True


if __name__ == '__main__':
    scheme = sys.argv[2]
    if scheme == 'http':
        http_server = WSGIServer(('0.0.0.0', int(sys.argv[1])), app)

    try:
        http_server.serve_forever()
    except KeyboardInterrupt:
        pass

